<!DOCTYPE html>
<html>
<head>
	<title>react-ref</title>
    <meta charset="UTF-8" />
	<script src='../node_modules/react/umd/react.development.js'></script>
	<script src='../node_modules/react-dom/umd/react-dom.development.js'></script>
    <script src='../node_modules/babel-standalone/babel.min.js'></script>
    <!--
        ref 类似原生dom操作
    -->
</head>
<body>
    <div id="my"></div>
    <script type="text/babel">
    class Hello extends React.Component{
        constructor(){
            super();
            this.state = {
                value:'abc'
            };
        };
        handleChange(e){
            this.setState({
                value:e.target.value 
            })
        };
        changeFocus(){
            this.refs.myText.focus();
            this.refs.myH.innerText='12345';
        };
        
        render(){ 
            return (
                <div>
                    <p>
                        <input type="text" ref="myText"/>
                    </p>
                    <h1 ref="myH"></h1>
                    <button onClick={()=>this.changeFocus()}>click</button>
                    <p>
                        <input type="text" value={this.state.value} 
                        onChange={(e)=>this.handleChange(e)}/>
                        <span>{this.state.value}</span>
                    </p>
                </div>
                )
        }
    };
    
     ReactDOM.render(
          <Hello/>,
        document.getElementById('my')
    )
    </script>
</body>
</html>